package com.ellricky.baselib.ui.order

import android.app.Activity
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.andr.common.ui.adapter.BaseRecyclerAdapter
import com.andr.common.ui.adapter.SmartViewHolder
import com.ellricky.baselib.R
import com.ellricky.baselib.entity.OrderInfo
import com.ellricky.baselib.widget.DetailItemView

class OrderAdapter(private val context: Activity) :
    BaseRecyclerAdapter<OrderInfo>(R.layout.base_adapter_order_manage) {

    override fun onBindViewHolder(holder: SmartViewHolder, info: OrderInfo, p2: Int) {
        holder.itemView.findViewById<DetailItemView>(R.id.tv_product_name).also {
            it.value = info.log_product_Name
        }

        holder.itemView.findViewById<DetailItemView>(R.id.tv_product_price).also {
            it.value = info.log_amount
        }
        holder.itemView.findViewById<DetailItemView>(R.id.tv_act_person).also {
            it.value = info.user_name
        }
        holder.itemView.findViewById<DetailItemView>(R.id.tv_act_time).also {
            it.value = info.log_createtime
        }

        holder.itemView.findViewById<TextView>(R.id.tv_confirm_status).also {
            when (info.log_confirm_state) {
                0 -> {
                    it.text = "未审核"
                    it.background = ContextCompat.getDrawable(it.context,R.drawable.base_bg_state_uncheck)
                }
                1 -> {
                    it.text = "已确认"
                    it.background = ContextCompat.getDrawable(it.context,R.drawable.base_bg_state_check_success)
                }
                2 -> {
                    it.text = "已驳回"
                    it.background = ContextCompat.getDrawable(it.context,R.drawable.base_bg_state_check_failure)
                }
            }
        }

        holder.itemView.findViewById<TextView>(R.id.tv_check_status).also {
            when (info.log_check_state) {
                0 -> {
                    it.text = "未审核"
                    it.background = ContextCompat.getDrawable(it.context,R.drawable.base_bg_state_uncheck)
                }
                1 -> {
                    it.text = "已确认"
                    it.background = ContextCompat.getDrawable(it.context,R.drawable.base_bg_state_check_success)
                }
                2 -> {
                    it.text = "已驳回"
                    it.background = ContextCompat.getDrawable(it.context,R.drawable.base_bg_state_check_failure)
                }
            }
        }
    }

}